<template>
    <div class="header">
        <div class="nav-logo"></div>
        <ul class="nav-right">
            <!-- <li class="nav-notification">
                <span class="icon-notification"><i>1</i></span>
                <span>消息</span>
                <i class="icon-line"></i>
            </li> -->
            <li class="nav-profile active">
                <div>
                    <span class="nav-avatar">
                        <img :src="headerPicture" id="topHeaderPic" style="border-radius:100%; border:1px solid #E7E7E7" alt="">
                    </span>
                    <span>{{testname}}</span>
                    <span class="icon-arrow"></span>
                </div>
                <ul>
                    <!-- <li><div class="nav-avatar"></div></li> -->
                    <li>
                        <router-link v-if="role === 1" :to="{path:'student-information'}">帐户设置</router-link>
                        <router-link v-if="role === 2" :to="{path:'administrator-modifiy'}">帐户设置</router-link>
                        <!-- <router-link :to='student-information'>帐户设置</router-link> -->
                        <!-- <a href="/account-setting">帐户设置</a> -->
                    </li>
                    <li>
                        <!-- <router-link to='/'>退出</router-link> -->
                        <a @click="layOut()">登出</a>
                    </li>
                </ul>
            </li>
        </ul>
    </div>
</template>
<script>
    export default {
        data(){
            return{
                testname:'',
                headerPicture:"../../static/image/touxiang.png",
                url:'',
                role: 1
            }
        },
        methods:{
            // 注销
            layOut(){
                this.$http.logOut(null,(res)=>{
                    console.log(res)
                     sessionStorage.removeItem("login");
                     this.$router.push({name:"Login"});
                })
            },
            // 初始化信息
            init(){
                if (JSON.parse(sessionStorage.getItem('login')).companyName) {
                    this.role = 2 // 企业
                }else{
                    this.role = 1 // 个人
                }
                this.testname = JSON.parse(sessionStorage.getItem('login')).name;
                this.headerPicture = JSON.parse(sessionStorage.getItem('login')).headPictureUrl;
            },
            // 跳转地址
            
        },
        created(){

        },
        mounted(){
            this.init();
        }
    }
</script>

